'use strict';

const Controller = require('egg').Controller;

class ListController extends Controller {
  async index() {
    const{ctx}=this;
    var db=this.app.mongodb;
    var res= await db.collection("article").find().toArray();
    var url=ctx.origin+"/public"
    res.forEach(item=>{
        item.imgSrc =url+item.imgSrc;
        item.avater =url+item.avater;
        item.headImgSrc =url+item.headImgSrc;
    })
    ctx.body={
        status:200,
        res
    }
  }
}

module.exports = ListController;
